08. Demographic Bias Analysis Walkthrough
Demographic Bias Analysis Walkthrough
ND320 AIHCND C01 L04 A07 Demographic Bias Analysis
Steps for Demographic Group Bias Analysis
- Select the groups we want to analyze: For this walkthrough, we selected the 'origin' field as a group to analyze and in this case it is for the country of origin for a car.
- Prepare the data: We use the boilerplate preprocessing code provided that takes a Pandas dataframe with the 'score' and 'label_value' fields.
from aequitas.preprocessing import preprocess_input_df
from aequitas.group import Group
from aequitas.plotting import Plot
from aequitas.bias import Bias
from aequitas.fairness import Fairness
ae_df, _ = preprocess_input_df(merged_binary_df)
g = Group()
xtab, _ = g.get_crosstabs(ae_df)
absolute_metrics = g.list_absolute_metrics(xtab)
clean_xtab = xtab.fillna(-1)
aqp = Plot()
b = Bias()
- Analyze different metrics with the groups: Then we can do different analyses such as TPR with the following function.
tpr = aqp.plot_group_metric(clean_xtab, 'tpr', min_group_size=0.05)
Code
If you need a code on the https://github.com/udacity.